<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var str = 'qwerqqeeeeeeeeeeeeeeqwrqqeqwrq'

    var obj = { } 

    for(var i = 0; i < str.length; i++) {
      if( obj[str[i]] ) {
         // 进来了 说明 对象存在这个属性
         obj[str[i]] += 1
      } else {
        obj[str[i]] = 1
      }
    }

    console.log(obj)

    var maxCount = 0  // 假设出现最多的是 0次
    var maxKey = ''

    for(var key in obj) {
      if(obj[key] > maxCount) {
        maxCount = obj[key]
        maxKey = key
      }
    }

    console.log('出现最多的字符是' + maxKey, '次数是' + maxCount)
  </script>
</body>
</html>